<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateRecordsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('records', function (Blueprint $table) {
            $table->foreignId('from_id')->comment('消息来源者id')->constrained('users')->onDelete('cascade');
            $table->foreignId('to_id')->comment('消息来源者id')->constrained('users')->onDelete('cascade');
            $table->text('content');
            $table->tinyInteger('push')->comment('是否需要推送? 0不需要推送 1需要 ')->default(0);
            $table->tinyInteger('read')->comment('是否已读? 0未读 1已读 ')->default(0);
            $table->tinyInteger('status')->comment('是否违规? 0违规 1不违规 ')->default(1);
            $table->string('type')->comment('消息类型');
            $table->string('uuid')->index()->comment('消息标识');
            $table->string('thumbnail')->nullable()->comment('视频缩略图');
            $table->double('length')->nullable()->comment('音频长度');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('records');
    }
}
